<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.longtop.com/intelliweb" prefix="e"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Insert title here</title>
	</head>
	<e:View id="view">
		<script type="text/javascript">SkinUtil.getSkin();</script>
		<script type="text/javascript">SkinUtil.getModuleSkin();</script>
		    
		<div id="Invisual Controls" style="min-height: 40px; background-color: LemonChiffon;" >
			<e:Dataset id="Dataset_FlowTeam" datasetDefinition="DatasetDefinition_sys.dsd" datasetRef="Dataset_FlowTeam" pageSize="10" loadDataCommand="Command_Load" allowMultiSelect="false">
				 <e:Field name="teamId" dataType="string" label="用户分组ID" maxLength="32" required="true"/>
				 <e:Field name="teamName" dataType="string" label="分组名称" maxLength="100" />
				 <e:Field name="userNameList" dataType="string" label="分组成员用户名" maxLength="1000" dropDown="LookupDropDown_User" required="true"/>
				 <e:Field name="userIdList" dataType="string" label="分组成员用户ID" maxLength="1000" required="true"/>
				 <e:Field name="sortNo" dataType="long" label="排序号" maxLength="4"  required="true"/>
				 <e:Field name="remark" dataType="string" label="备注" maxLength="200" />
			</e:Dataset>
			
			<e:Command id="Command_Search" action="com.longtop.framework.sys.flow.web.FlowTeamListAction" method="searchFlowTeam" submitForm="true" submitFormScope="all" validateRequired="true">
				<e:DatasetInfo name="DatasetInfo2" dataset="Dataset_FlowTeam" alwayRefreshClient="true" submitType="none"></e:DatasetInfo>
			</e:Command>
			<e:Command id="Command_Save" action="com.longtop.framework.sys.flow.web.FlowTeamListAction" method="saveFlowTeam" submitForm="true" validateRequired="true" onExecuteSuccess="Button_Search_onClick()">
				<e:DatasetInfo name="DatasetInfo4" dataset="Dataset_FlowTeam" alwayRefreshClient="false" submitType="changes"></e:DatasetInfo>
			</e:Command>
			<e:Command id="Command_Load" action="com.longtop.framework.sys.flow.web.FlowTeamListAction" method="loadFlowTeam" showHintInfoOnSuccess="false">
				<e:DatasetInfo name="DatasetInfo3" dataset="Dataset_FlowTeam" alwayRefreshClient="true"></e:DatasetInfo>
			</e:Command>
			
			<e:LookupDropDown id="LookupDropDown_User" path="/jsp/framework/sys/user/userDropdown.jsp"	windowWidth="700" windowHeight="450" 
					autoDropDown="true" fixed="true" onSelect="LookupDropDown_User_onSelect(dropdown,iframe,text)" windowCaption="选择员工">
			</e:LookupDropDown>
		</div>
		
		<body>
			<e:Page id="ePage" action="com.longtop.framework.sys.flow.web.FlowTeamListAction" style="min-height: 80px; width: 100%; height: 100%;">
				<table style="width: 100%; height: 100%;" border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
					<tr>
						<td align="left" valign="top">
							<e:Panel id="Panel_Search" style="width: 285px; height: 100%" caption="查询条件" captionIcon="/images/query_win.gif" captionStyle="color:#888888" allowFold="true"  showArrowButton="false">
								<table style="text-align: left; width: 100%;" border="0" cellpadding="3" cellspacing="3" width="100%" align="center">
									<tr>
										<td width="80px" align="right">
											<e:Label id="Label_teamId" caption="用户组ID" />
										</td>
										<td>
											<e:Text id="Text_teamId" style="width: 169px" ></e:Text>
										</td>
									</tr>
									<tr>
										<td align="right">
											<e:Label id="Label_teamName" caption="用户分组名称"></e:Label>
										</td>
										<td>
											<e:Text id="Text_teamName" style="width:169px;"></e:Text>
										</td>
									</tr>
									<tr>
										<td align="right">
											<e:Label id="Label_remark" caption="备注" />
										</td>
										<td>
											<e:Text id="Text_remark" style="width: 169px" ></e:Text>
										</td>
									</tr>
									<tr>
										<td></td>
										<td>
											<e:Button id="Button_Search" style='height: 22px; width: 70px' caption="查询" command="Command_Search" icon="/images/query.gif" onClick="Button_Search_onClick()"></e:Button>&nbsp;&nbsp;
										</td>	
									</tr>
								</table>
							</e:Panel>
						</td>
						<td valign="top" width="100%">
							<e:Panel id="Panel_Result" style="width: 100%; height: 100%" captionStyle="color:#888888" caption="查询结果列表" captionIcon="/images/list_win.gif">
								<table style="text-align: left; width: 100%;" border="0" cellpadding="3" cellspacing="3" >
									<tr>
										<td>
											<table style="text-align: left; width: 100%;" border="0" cellpadding="0" cellspacing="0">
												<tr>
													<td height="27px" width="1%">
														<e:RecordNavigator id="RecordNavigator_Index" dataset="Dataset_FlowTeam" showNavigatorButton="false">
															<e:RecordButton id="RecordButton_insert" label="新增" onClick="insertRecord" icon="/images/add.gif"></e:RecordButton>
															<e:RecordButton id="RecordButton_delete" label="删除" onClick="deleteRecord" icon="/images/delete.gif"></e:RecordButton>
															<e:RecordButton id="RecordButton_save" label="保存" icon="/images/submit.gif" onClick="RecordButton_save_onClick()"></e:RecordButton>
														</e:RecordNavigator>
													</td>
													<td align="left" width="99%"><e:PageNavigator id="PageNavigator_FlowTeam" dataset="Dataset_FlowTeam" showRecordNum="true"></e:PageNavigator></td>
												</tr>
											</table>
										</td>
									</tr>
									<tr>
										<td>
											<e:Grid id="Grid_FlowTeam" style="width: 100%; height: 100%;" showIndex="true" dataset="Dataset_FlowTeam" onClick="Grid_FlowTeam_onClick()" >
											</e:Grid>
										</td>
									</tr>
								</table>
							</e:Panel>
						</td>
					</tr>
			    </table>
			</e:Page>
		</body>
		<script type="text/javascript">
			
			//查询
			function Button_Search_onClick(){
			    Command_Search.execute();
			}
			//保存
			function RecordButton_save_onClick(){
			    Command_Save.execute();
			}	
			
			//单击记录,确定主键是否可编辑
			function Grid_FlowTeam_onClick(){
				var element = event.srcElement;
				if(element.isDataCell){
					if(element.isDataCell){
				        var currentRecord = element.record;
				        if(currentRecord.state == Constant.RECORD.STATE_NEW || currentRecord.state == Constant.RECORD.STATE_INSERT) {
			          		currentRecord.dataset.getField("teamId").setReadOnly(false);
			          	} else{
					        currentRecord.dataset.getField("teamId").setReadOnly(true);
			       		}
					}
				}
			}
				
			//选择员工
			function LookupDropDown_User_onSelect(dropdown,iframe,text){
				var dataset = $J(iframe.Dataset_User);
				var record_data=$J("Dataset_FlowTeam").getCurrentRecord();
				if(dataset){
				    var record = dataset.getCurrentRecord();
				    if(typeof record != "undefined" && record != null){
				    	var userNameList= record_data.getValue("userNameList");
				    	var userIdList= record_data.getValue("userIdList");
				    	if(userNameList==''||userNameList==null){
				    		record_data.setValue("userNameList",record.getValue("userName"));
				    		record_data.setValue("userIdList",record.getValue("userId"));
				    	}
				    	else{
				    		record_data.setValue("userNameList",userNameList+","+record.getValue("userName"));
				    		record_data.setValue("userIdList",userIdList+","+record.getValue("userId"));
				    	}
				    }
				}
			}
		</script>
	</e:View>
</html>
